export default {
    // 全局的web server
    webUrl: ()=>{
        return 'http://www.gryns.cn:8180'
    },
    /**
	 * handlebars 模板引擎
	 * id: 模板id 例如：‘id’
	 * data: 后台返回的数据
	 */
	handlebarsHtml:(id,data) =>{
		var tpl = Handlebars.compile($('#'+id).html());
		return tpl(data);
	},
	/**
	 * 语法高亮 添加行号
	 **/
	addNum:that =>{
		let texts = $(that).text().replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
		.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&#39;').replace(/"/g, '&quot;')        
		var codetext = texts.split('\n');
		var code = '';
		$(codetext).each(function(v){
			code += '<li>'+codetext[v]+'</li>';
		})        
		code = '<ol>'+code+'</ol>';
		$(that).html(code);
	},
	/*
	设置标题，mate属性
	titleText: 标题
	keywords: 关键字
	description:对网站的描述
	*/
	setTitle:(title,keywords,description) =>{
		let titleText = "<title>"+title+"</title>";
		let keywordsText = '<meta name="keywords" content="'+keywords+'">';
		let descriptionText = '<meta name="description" content="'+description+'"> ';
		return keywordsText +''+descriptionText + '' + titleText;
	}
}